#!/bin/sh

# 2016010731 First release  by wuyang

# shell name:  cut_tomcatLog.sh


PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin

export PATH

. ~/.bashrc

export LANG=C



function cut_logs () {
    if [ $# -ne 1 ];then
        echo 'please input log_path'
        exit 1;

    else
        time=$(date +%Y-%m-%d)

        if [ -f $1/catalina.$time.out ];then
                time=$(date +%Y-%m-%d-%T)
                [ -f $1/catalina.out ] && cd $1 && cp catalina.out catalina.$time.out && >catalina.out && echo $1 ok  ;
        else
                [ -f $1/catalina.out ] && cd $1 && cp catalina.out catalina.$time.out && >catalina.out && echo $1 ok  ;
        fi
   fi
}

echo '--------------begin cut app tomcat logs--------------'
cut_logs  "/usr/local/tomcat/project/server/logs"